package com.cy.stone.framework.mybatisflex;

import cn.dev33.satoken.stp.StpUtil;
import com.cy.stone.common.base.BaseEntity;
import com.mybatisflex.annotation.UpdateListener;

/**
 * 更新监听
 * @author Wings
 * @since 2023-12-16
 */
public class DefaultUpdateListener implements UpdateListener {
    @Override
    public void onUpdate(Object o) {
        BaseEntity entity = (BaseEntity) o;
        String updateBy;
        try {
            updateBy = StpUtil.getLoginIdAsString();
        } catch (Exception e) {
            updateBy = "System";
        }
        entity.setUpdateBy(updateBy);
    }
}
